#ifndef INFINITY_SERVICE_GRAPHICS_INL
#	define INFINITY_SERVICE_GRAPHICS_INL

#include "graphics/graphicsmanager.h"
#include "graphics/renderer.h"

namespace infinity {

inline ServiceGraphics::ServiceGraphics()
:	super()
,	m_renderWindow(NULL)
,	m_pipelines(PIPELINES_COUNT)
{
	//! @todo move this to initializeMedia...
	//! @todo m_renderWindow = dw::graphics::GraphicsManager::getInstance().createRenderWindow();
	m_renderWindow = dw::graphics::GraphicsManager::getInstance().getBackend().createRenderWindow();
	m_renderWindow->setClearColor(dw::graphics::Colorf::LightBlue);
	m_renderWindow->setClearMode(dw::graphics::RenderTarget::COLOR_AND_DEPTH);
	dw::graphics::GraphicsManager::getInstance().getRenderer().setRenderTarget(m_renderWindow);
}

template< class MeshT >
graphics::Mesh* ServiceGraphics::createMesh(Groups group, const std::string& name)
{
	dwAssert(m_meshes.find(name) == m_meshes.end(), "Invalid parameter: name is already registered");

	MeshT* newMesh = new MeshT(
		dw::graphics::BufferObject::update_never, dw::graphics::IndexBuffer::uint16,
		dw::graphics::primitive::triangles, m_groups[group].vertexFormat);
	newMesh->m_isManaged = true;

	m_meshes.insert(std::make_pair(name, newMesh));

	return newMesh;
}

} // namespace infinity

#endif // !INFINITY_SERVICE_GRAPHICS_INL
